import useSWR, {SWRConfiguration, SWRResponse } from "swr";
import { AxiosRequestConfig,  AxiosError } from "axios";
import axiosInstance from "@/hooks/useRequest/axiosInstance";
function useRequest<Data = unknown, error = unknown>(request: AxiosRequestConfig, config?: SWRConfiguration) {
  const { data, error } = useSWR<any, AxiosError<Error>>(request.url, () => axiosInstance.request(request), () => axiosInstance.request(request));
  return (
    data,
    error
  );
 }
 export default useRequest;
